<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Extracts an attribute</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.radius-demangle.html">« radius_demangle</a></li>
      <li style="float: right;"><a href="function.radius-get-tagged-attr-data.html">radius_get_tagged_attr_data »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.radius.html">Radius 函数</a></li>
    <li>Extracts an attribute</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.radius-get-attr" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">radius_get_attr</h1>
  <p class="verinfo">(PECL radius &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">radius_get_attr</span> &mdash; <span class="dc-title">Extracts an attribute</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.radius-get-attr-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>radius_get_attr</strong></span>(<span class="methodparam"><span class="type">resource</span> <code class="parameter">$radius_handle</code></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   Like Radius requests, each response may contain zero or more attributes.
   After a response has been received successfully by
   <span class="function"><a href="function.radius-send-request.html" class="function">radius_send_request()</a></span>, its attributes can be extracted
   one by one using <span class="function"><strong>radius_get_attr()</strong></span>. Each time
   <span class="function"><strong>radius_get_attr()</strong></span> is called, it gets the next attribute
   from the current response.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.radius-get-attr-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    <dt>
<code class="parameter">radius_handle</code></dt>
<dd>
<p class="para">The RADIUS resource.</p></dd>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.radius-get-attr-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an associative array containing the attribute-type and the data, or
   error number &lt;= 0.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.radius-get-attr-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-693">
    <p><strong>示例 #1 <span class="function"><strong>radius_get_attr()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">while&nbsp;(</span><span style="color: #0000BB">$resa&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">radius_get_attr</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">))&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">is_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$resa</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Error&nbsp;getting&nbsp;attribute:&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;&nbsp;</span><span style="color: #0000BB">radius_strerror</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$attr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$resa</span><span style="color: #007700">[</span><span style="color: #DD0000">'attr'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$resa</span><span style="color: #007700">[</span><span style="color: #DD0000">'data'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Got&nbsp;Attr:%d&nbsp;%d&nbsp;Bytes&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$attr</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">));<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.radius-get-attr-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.radius-put-attr.html" class="function" rel="rdfs-seeAlso">radius_put_attr()</a> - Attaches a binary attribute</span></li>
    <li class="member"><span class="function"><a href="function.radius-get-vendor-attr.html" class="function" rel="rdfs-seeAlso">radius_get_vendor_attr()</a> - Extracts a vendor specific attribute</span></li>
    <li class="member"><span class="function"><a href="function.radius-put-vendor-attr.html" class="function" rel="rdfs-seeAlso">radius_put_vendor_attr()</a> - Attaches a vendor specific binary attribute</span></li>
    <li class="member"><span class="function"><a href="function.radius-send-request.html" class="function" rel="rdfs-seeAlso">radius_send_request()</a> - Sends the request and waits for a reply</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>